<form class="layui-form" action="{:url('mp/OutNodeProgress/returnTime')}" id="onClickOrderActionTplform">
    <h2 class="layui-colla-title">MES同步信息</h2>
    <table class="layui-table small-table">
        <thead>
        <tr>
            <th>MES车缝价</th>
            <th>MES倍率</th>
            <th>MES加工费（元）</th>
            <th>MES长款补贴单价（元）</th>
        </tr>
        </thead>
        <tbody>
        {if env('env_site')=='riwei' }
        <tr>
            <td>
                <input type="text" class=" layui-input" name="cost_jiagong_littleSumCost" style="width:80px;"
                       value="{$info.cost_jiagong_littleSumCost}" onchange="set_unit_fun()" autocomplete="off">
            </td>
            <td>
                <input type="text" class=" layui-input" name="cost_jiagong_scale" style="width:80px;"
                       value="{$info.cost_jiagong_scale}" onchange="set_unit_fun()" autocomplete="off">
            </td>
            <td>
                <input type="text" class=" layui-input" name="cost_jiagong_sumCostForSale" style="width:80px;"
                       value="{$info.cost_jiagong_sumCostForSale}" onchange="set_unit_fun()" autocomplete="off">
            </td>
            <td>{$info.dress_changkuan_unitPrice}</td>
        </tr>
        {else /}
        <tr>
            <td>{$info.cost_jiagong_littleSumCost}</td>
            <td>{$info.cost_jiagong_scale}</td>
            <td>{$info.cost_jiagong_sumCostForSale}</td>
            <td>{$info.dress_changkuan_unitPrice}</td>
        </tr>
        {/if}
        </tbody>
    </table>
    <h2 class="layui-colla-title">订单号： {$info.client_ordernum}</h2>
    <table class="layui-table small-table">
        <thead>
        <tr>
            <th>委外类型</th>
            <th>委外倍率（车缝价）</th>
            <th>手工/专机单价</th>
            <th>长款补贴倍率</th>
            <th>长款补贴单价</th>
            <th>委外单价</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>
                <div class="layui-input-inline" id="u_out_type" style="width: auto;min-width: 200px;">
                </div>
            </td>
            <td>
                <input type="text" class=" layui-input" name="u_scale" onchange="set_unit_fun()" style="width:80px;"
                       value="{$info.u_scale}" autocomplete="off" placeholder="输入倍率">
            </td>
            <td>
                <input type="text" class=" layui-input" name="u_price_manual" onchange="set_unit_fun()"
                       style="width:80px;" value="{$info.u_price_manual}" autocomplete="off" placeholder="输入单价"
                       lay-verify="number">
            </td>
            <td>
                <input type="text" class=" layui-input" name="u_scale_changkuan" onchange="set_unit_fun()"
                       style="width:80px;" value="{$info.u_scale_changkuan}" autocomplete="off" placeholder="输入倍率"
                       lay-verify="number">
            </td>
            <td id="changkuan_price">
                0元
            </td>
            <td id="out_type_price">
                0元
            </td>
        </tr>
        </tbody>
    </table>
    <div class="layui-inline fr" style="margin: 20px 20px;">
        <input type="hidden" name="order_id" value="{$info.order_id}">
        <button type="button" class="layui-btn layui-btn-normal" id="submitonClickOrderActionform">确定</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>


{include file="system@block/layui" /}
<script src="__PUBLIC_JS__/jquery.2.1.4.min.js?v={:config('hisiphp.version')}"></script>
<script src="__PUBLIC_JS__/xm-select/dist/xm-select.js?v={:config('hisiphp.version')}"></script>
<script src="__PUBLIC_JS__/vue@3.2.26/dist/vue.global.js"></script>
<script type="text/javascript">
    var g_id = {$info['g_id']};
    var mes_res_code = {$mes_res_code};
    var mes_res_msg = "{$mes_res_msg}";
    var info_json = JSON.parse('{:json_encode($info)}');
    var type = '{$type}';
    layui.use(['element', 'layer', 'laytpl', 'tool', 'laydate', 'table', 'form', 'flow'], function () {
        var element = layui.element;
        var layer = layui.layer;
        var $ = layui.jquery;
        var form = layui.form;
        var laytpl = layui.laytpl, laydate = layui.laydate, table = layui.table;
        var flow = layui.flow;
        set_unit_fun();

        $(document).on('click', '#submitonClickOrderActionform', function (e) {
            e.stopPropagation();
            $.ajax({
                type: "POST",
                url: "{:url('mp/OutNodeProgress/unitSet')}",
                data: $('#onClickOrderActionTplform').serialize(),
                dataType: "json",
                success: function (res) {
                    if (res.code == 1) {
                        window.parent.location.reload();
                        parent.layer.closeAll();
                    } else {
                        layer.msg(res.msg, {icon: 2, anim: 6});
                    }
                }
            });
            return false;
        });
        if (g_id == 0) {
            layer.confirm('请先分工厂/分组，再重新打开此窗口。', {btn: ['确定']}, function (index) {
                parent.layui.layer.closeAll();
                layer.close(index);
            });
        }
        if (mes_res_code > 0) {
            layer.confirm(mes_res_msg, {btn: ['确定']}, function (index) {
                parent.layui.layer.closeAll();
                layer.close(index);
            });
        }
    });

    var u_out_type_json = JSON.parse('{:json_encode($u_out_type_array)}');
    var u_out_type = xmSelect.render({
        el: '#u_out_type',
        name: 'u_out_type',
        // autoRow: true,
        // filterable: true,
        tree: {
            show: true,
            showFolderIcon: true,
            showLine: true,
            indent: 20,
            expandedKeys: [-3],
        },
        // toolbar: {
        //     show: true,
        //     list: ['ALL', 'REVERSE', 'CLEAR']
        // },
        data: function () {
            return u_out_type_json;
        }
    })

    function set_unit_fun() {
        var dress_changkuan_unitPrice = parseFloat($('[name="dress_changkuan_unitPrice"]').val());
        if (dress_changkuan_unitPrice > 0) info_json.dress_changkuan_unitPrice = dress_changkuan_unitPrice;
        var cost_jiagong_littleSumCost = parseFloat($('[name="cost_jiagong_littleSumCost"]').val());
        if (cost_jiagong_littleSumCost > 0) info_json.cost_jiagong_littleSumCost = cost_jiagong_littleSumCost;
        var dress_changkuan_unitPrice = parseFloat($('[name="dress_changkuan_unitPrice"]').val());
        if (dress_changkuan_unitPrice > 0) info_json.dress_changkuan_unitPrice = dress_changkuan_unitPrice;

        var u_scale = $('[name="u_scale"]').val();
        var u_price_manual = $('[name="u_price_manual"]').val();
        var u_scale_changkuan = $('[name="u_scale_changkuan"]').val();
        $('#changkuan_price').html(((parseFloat(info_json.dress_changkuan_unitPrice) * parseFloat(u_scale_changkuan)).toFixed(2)) + "元");
        var temp0 = parseFloat(info_json.cost_jiagong_littleSumCost) * parseFloat(u_scale);
        var temp1 = parseFloat(info_json.dress_changkuan_unitPrice) * parseFloat(u_scale_changkuan);
        var temp2 = temp0 + temp1 + parseFloat(u_price_manual);
        $('#out_type_price').html(temp2.toFixed(2) + "元");
    }
</script>